package com.cloud.model.system;


import com.cloud.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

/**
 * A SysResource.
 */
@Entity
@Table(name = "sys_resource")
@EntityListeners(AuditingEntityListener.class)
public class SysResource extends BaseEntity {

    @Column(name = "resource_name")
    @NotBlank(message = "菜单名不能为空")
    private String resourceName;
    @Column(name = "resource_url")
    private String resourceUrl;

    @Column(name = "resource_permission")
    @NotBlank(message = "权限不能为空")
    private String resourcePermission;

    @ManyToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE})
    @JoinColumn(name = "resource_pid")
    @JsonIgnore
    private SysResource sysResource;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getResourceName() {
        return resourceName;
    }

    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }

    public String getResourceUrl() {
        return resourceUrl;
    }

    public void setResourceUrl(String resourceUrl) {
        this.resourceUrl = resourceUrl;
    }

    public String getResourcePermission() {
        return resourcePermission;
    }

    public void setResourcePermission(String resourcePermission) {
        this.resourcePermission = resourcePermission;
    }


    public SysResource getSysResource() {
        return sysResource;
    }

    public void setSysResource(SysResource sysResource) {
        this.sysResource = sysResource;
    }

    @Override
    public String toString() {
        return "SysResource{" +
                "id=" + id +
                ", resourceName='" + resourceName + '\'' +
                ", resourceUrl='" + resourceUrl + '\'' +
                ", resourcePermission='" + resourcePermission + '\'' +
                ", sysResource=" + sysResource +
                '}';
    }
}
